using System;
using System.Threading.Tasks;
public class BaiduPanSDK_Examples01 {
    public static async Task Main() {
        // 1. 授权（实际应用中需引导用户跳转授权页，获取code）
        var auth = new BaiduPanAuth();
        Console.WriteLine("请访问以下地址授权：" + auth.GetAuthorizationUrl());
        Console.Write("请输入回调返回的code：");
        var code = Console.ReadLine();
        var tokenResult = await auth.GetAccessToken(code);
        var accessToken = tokenResult["access_token"].ToString();

        // 2. 上传文件
        var uploader = new BaiduPanUploader(accessToken);
        var uploadResult = await uploader.UploadFile(@"C:\test\example.txt", "/我的上传目录");
        Console.WriteLine("上传结果：" + uploadResult.ToString());

        // 3. 下载文件
        var downloader = new BaiduPanDownloader(accessToken);
        await downloader.DownloadFile("/我的上传目录/example.txt", @"C:\download\example.txt");
        Console.WriteLine("下载完成");
    }
}
